<template>
	<view class="w100 h100">
		<view class="uni-container mt10">
			<uni-table ref="table" border stripe emptyText="暂无明细">
				<uni-tr>
					<uni-th align="center">ID</uni-th>
					<uni-th align="center">酒品名称</uni-th>
					<uni-th align="center">酒品图片</uni-th>
					<uni-th align="center">单位</uni-th>
					<uni-th align="center">有效期(天)</uni-th>
					<uni-th align="center">存酒数</uni-th>
					<uni-th align="center">取酒数</uni-th>
					<uni-th align="center">已过期</uni-th>
					<uni-th align="center">状态</uni-th>
					<uni-th align="center">操作</uni-th>
				</uni-tr>
				<uni-tr v-for="(row, i) in orderList" :key="i">
					<uni-td>{{ row.id }}</uni-td>
					<uni-td>{{ row.name }}</uni-td>
					<uni-td align="center" class="cpd">
						<view class="f-c"><image class="pplg" :src="row.logo" mode="" /></view>
					</uni-td>
					<uni-td align="center">{{ row.unit }}</uni-td>
					<uni-td align="center">{{ row.day }}</uni-td>
					<uni-td align="center">{{ row.statistics && row.statistics.depositCount }}</uni-td>
					<uni-td align="center">{{ row.statistics && row.statistics.fetchCount }}</uni-td>
					<uni-td align="center">{{ row.statistics && row.statistics.expiredCount }}</uni-td>
					<uni-td align="center">
						<view class="f-1 f-c">
							<u-switch v-model="row.state" :inactiveValue="0" :activeValue="1"
								:activeColor="subColor" size="18"  @change="changePri(row)">
							</u-switch>
						</view>
					</uni-td>
					<uni-td align="center">
						<text class="cf06 mr10" @click.stop="handEdit(row)">编辑</text>
						<text class="cf06 mr10" @click.stop="handDel(row)">删除</text>
					</uni-td>
				</uni-tr>
			</uni-table>
			<view class="uni-pagination-box"><uni-pagination show-icon :page-size="queryForm.pageSize"
					:current="queryForm.pageNo" :total="total" @change="change" /></view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			orderList: {
				type: Array,
				default () {
					return []
				}
			},
			current: {
				type: Number,
				default: 0
			},
			queryForm:{
				type: Object,
				default () {
					return {}
				}
			},
			total: {
				type: Number,
				default: 0
			},
		},
		data() {
			return {
				subColor: uni.getStorageSync('subject_color'),
			}
		},
		methods: {
			tocenter(e) {
				uni.makePhoneCall({
					phoneNumber: e
				});
			},
			toDtail(v) {
				return
				uni.navigateTo({
					url: `/pages/order/detail?id=${v.id}`
				})
			},
			handEdit(v){
				uni.navigateTo({
					url: `/pages/order/wineStock/wineAdd?id=${v.id}`
				})
			},
			
			async changePri(v){
				let {
					msg
				} = await this.beg.request({
					url: `${this.api.dState}/${v.id}`,
					method: "POST",
					data:{
						id:v.id
					}
				})
				this.$emit('fetchData')
				uni.$u.toast(msg)
			},
			
			handDel(v){
				uni.showModal({
					title: '温馨提示',
					content: '你确定要删除当前项吗',
					success: async (res) => {
						if (res.confirm) {
							let {
								msg
							} = await this.beg.request({
								url: `${this.api.drinks}/${v.id}`,
								method: "DELETE",
							})
							this.$emit('fetchData')
							uni.$u.toast(msg)
						}
					}
				});
			},
			change(e){
				this.$emit('fetchData',e)
			},
		}
	}
</script>

<style lang="scss" scoped>
	.cpd{
		
	}
	.pplg{
		width: 40rpx;
		height: 40rpx;
		border-radius: 10rpx;
	}
</style>